#!/usr/bin/env zsh
# Description:
#   Installation directory which is managed by zplug

local    arg="${1:gs:@::}" package
local -a parsed_zplugs
local    dir
local    default="$ZPLUG_REPOS/$arg"

package="${arg}, ${zplugs[$arg]%, }"
parsed_zplugs=(${(s/, /)package/,  */, })

dir="${parsed_zplugs[(k)dir:*]#dir:*}"
if [[ -z $dir ]]; then
    zstyle -s ":zplug:tag" dir dir
fi

local from
__zplug::core::core::run_interfaces \
    'from' \
    "$arg" \
    | read from

case "$from" in
    "oh-my-zsh")
        dir="$ZPLUG_REPOS/$_ZPLUG_OHMYZSH"
        ;;
    "prezto")
        dir="$ZPLUG_REPOS/$_ZPLUG_PREZTO"
        ;;
    "local")
        dir="$arg"
        ;;
esac

echo ${~dir:-$default}
